// pages/index/clearCar/clearCarDetail/clearCarDetail.js
const app = getApp()
const request = require('../../../../utils/request')

Page({
  data: {
    indicatorDots: true,  //是否显示面板指示点
    autoplay: true,      //是否自动切换
    interval: 3000,       //自动切换时间间隔
    duration: 1000,       //滑动动画时长
    goods_id: 0
  },

  onLoad: function (options) {
    this.setData({
      goods_id: options.goods_id
    })
    this.getDetail()
  },

  getDetail() {
    wx.showLoading()
    request.get('goods_detail', { id: this.data.goods_id })
      .then(res => {
          wx.hideLoading()
          res.data.imgs.forEach(item => {
            item = app.d.imgPath + item
          })

          this.setData({
            imgs: res.data.imgs,
            price: res.data.price && res.data.price || '',
            title: res.data.title && res.data.title || '',
            detail: res.data.detail && res.data.detail || ''
          })
      })
      .catch(error => {
        wx.showToast({
          icon: 'none',
          title: error.msg
        })
      })
      .finally(_ => {
        
      })
  },
})
